import 'dart:math';

import 'package:xinxuan/utils/sign_util.dart';
import 'package:common_utils/common_utils.dart';

class ParamUtil {

  static final Random rng = new Random(); 
  
  static Map<String, dynamic> param(Map<String, dynamic> paramMap) {
    if (paramMap.isEmpty) {
      paramMap = {};
    }
    String noncestr = '';
    for (int i = 0; i < 6; i++) { 
      noncestr += rng.nextInt(9).toString();
    }
    paramMap.putIfAbsent('noncestr', () => noncestr);
    int timestamp = NumUtil.getNumByValueDouble(NumUtil.divide(DateTime.now().millisecondsSinceEpoch, 1000), 0) as int;
    paramMap.putIfAbsent('timestamp', () => timestamp);
    paramMap.putIfAbsent('signature', () => SignUtil.getSign(paramMap));
    return paramMap;
  }

}